home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / DRAWBMP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-06  |  1.9 KB  |  73 lines

  1. /*
  2.  * the class DRAW_BMP_INFO
  3.  * Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
  4.  */
  5.  
  6. #include "stdafx.h"
  7.  
  8. #include "kbandef.h"
  9.  
  10. #include "drawbmp.h"
  11.  
  12. DRAW_BMP_INFO::DRAW_BMP_INFO(const XY& ac_min, const XY& ac_max, int dpi_design, int dpi_bmp)
  13. {
  14.   m_mat_size       = double(dpi_bmp) / double(dpi_design);
  15.   m_pc_design_size = XY(XYT(X_SIZE * m_mat_size), XYT(Y_SIZE * m_mat_size));
  16.   XY pc_min_dis    = ac_min * m_mat_size;
  17.   XY pc_max_dis    = ac_max * m_mat_size;
  18.   XY pc_min_src    = XY(pc_min_dis.x(), m_pc_design_size.y() - pc_min_dis.y());
  19.   XY pc_max_src    = XY(pc_max_dis.x(), m_pc_design_size.y() - pc_max_dis.y());
  20.   XY pc_min        = get_min(pc_min_src, pc_max_src);
  21.   XY pc_max        = get_max(pc_min_src, pc_max_src);
  22.   m_pc_win_base    = pc_min;
  23.   m_pc_win_size    = pc_max - pc_min + 1;
  24. }
  25.  
  26. XYT DRAW_BMP_INFO::xmin(void) const { return 0; }
  27. XYT DRAW_BMP_INFO::xmax(void) const { return pc_win_size().x() - 1; }
  28. XYT DRAW_BMP_INFO::ymin(void) const { return 0; }
  29. XYT DRAW_BMP_INFO::ymax(void) const { return pc_win_size().y() - 1; }
  30.  
  31. XYT DRAW_BMP_INFO::distance_ac2pc(XYT ac) const
  32. {
  33.   return XYT(ac * m_mat_size);
  34. }
  35.  
  36. void DRAW_BMP_INFO::xy_ac2pc(const XY& ac, XY& pc) const
  37. {
  38.   XY pc_math = ac * m_mat_size;
  39.   pc.set_x(                       pc_math.x());
  40.   pc.set_y(m_pc_design_size.y() - pc_math.y());
  41.   pc -= m_pc_win_base;
  42. }
  43.  
  44. XY DRAW_BMP_INFO::pc_win_size(void) const
  45. {
  46.   return m_pc_win_size;
  47. }
  48.  
  49. COLORREF DRAW_BMP_INFO::get_grid_color(void) const
  50. {
  51.   return RGB(255, 255, 255);
  52. }
  53.  
  54. COLORREF DRAW_BMP_INFO::get_cursor_color(void) const
  55. {
  56.   return RGB(255, 255, 255);
  57. }
  58.  
  59. COLORREF DRAW_BMP_INFO::get_target_color(void) const
  60. {
  61.   return RGB(255, 255, 255);
  62. }
  63.  
  64. COLORREF DRAW_BMP_INFO::get_erase_color(void) const
  65. {
  66.   return RGB(255, 255, 255);
  67. }
  68.  
  69. COLORREF DRAW_BMP_INFO::get_layer_color(int layer) const
  70. {
  71.   return RGB(  0,   0,   0);
  72. }
  73.